package com.sondon.mayi.adapter;

import java.util.ArrayList;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import com.sondon.mayi.entity.OrderInfo;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * @Project : Fruit
 * @Package : com.sondon.mayi.adapter
 * @Class : OrderListAdapter.java
 * @Author : 蔡文锋
 * @DateTime：2015-6-18 下午1:34:43
 * @Blog：http://blog.csdn.net/caiwenfeng_for_23
 * @Description : { 订单列表适配器 }
 */
@EBean
public class OrderListAdapter extends BaseAdapter {
	@RootContext
	Context context;
	ArrayList<OrderInfo> datas=new ArrayList<OrderInfo>();
	
	public void SetData(ArrayList<OrderInfo> datas){
		this.datas.clear();
		if(datas !=null && datas.size()>0){
			this.datas.addAll(datas);
		}
		notifyDataSetChanged();
	}
	
	@Override
	public int getCount() {
		return this.datas.size();
	}

	@Override
	public Object getItem(int position) {
		return this.datas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View currentView, ViewGroup perent) {
		OrderList_Item item=null;
		if(currentView==null){
			item=OrderList_Item_.build(context);
		}else{
			item=(OrderList_Item) currentView;
		}
		item.bindData(this.datas.get(position));
		return item;
	}

}
